package part5;

/**
 * @author wcj
 * @Date 2021/5/13 15:05
 * @Version 1.0
 */
public class Part52 {
    public void f1(char x) {
        System.out.println("f1 char");
    }

    public void f1(byte x) {
        System.out.println("f1 byte");
    }

    public void f1(short x) {
        System.out.println("f1 short");
    }

    public void f1(int x) {
        System.out.println("f1 int");
    }

    public void f1(long x) {
        System.out.println("f1 long");
    }

    public void f1(float x) {
        System.out.println("f1 float");
    }

    public void f1(double x) {
        System.out.println("f1 double");
    }

    public void f2(byte x) {
        System.out.println("f2 byte");
    }

    public void f2(short x) {
        System.out.println("f2 short");
    }

    public void f2(int x) {
        System.out.println("f2 int");
    }

    public void f2(long x) {
        System.out.println("f2 long");
    }

    public void f2(float x) {
        System.out.println("f2 float");
    }

    public void f2(double x) {
        System.out.println("f2 double");
    }

    public void f3(short x) {
        System.out.println("f3 short");
    }

    public void f3(int x) {
        System.out.println("f3 int");
    }

    public void f3(long x) {
        System.out.println("f3 long");
    }

    public void f3(float x) {
        System.out.println("f3 float");
    }

    public void f3(double x) {
        System.out.println("f3 double");
    }

    public void f4(int x) {
        System.out.println("f4 int");
    }

    public void f4(long x) {
        System.out.println("f4 long");
    }

    public void f4(float x) {
        System.out.println("f4 float");
    }

    public void f4(double x) {
        System.out.println("f4 double");
    }

    public void f5(long x) {
        System.out.println("f5 long");
    }

    public void f5(float x) {
        System.out.println("f5 float");
    }

    public void f5(double x) {
        System.out.println("f5 double");
    }

    public void f6(float x) {
        System.out.println("f6 float");
    }

    public void f6(double x) {
        System.out.println("f6 double");
    }

    public void f7(double x) {
        System.out.println("f7 double");
    }

    /**
     * 方法重载的情况下，如果参数类型为char，首先寻找char类型的形参，如果没有char可以转换为int,long,float,double
     */
    public void testChar() {
        char c = 'x';
        f1(c);
        f2(c);
        f3(c);
        f4(c);
        f5(c);
        f6(c);
        f7(c);
    }

    /**
     * byte可以向上的所有基本数据类型转换，除了boolean
     */
    public void testByte() {
        byte c = 0;
        f1(c);
        f2(c);
        f3(c);
        f4(c);
        f5(c);
        f6(c);
        f7(c);
    }

    /**
     * short也是可以向上转，但是不能自动窄转化
     */
    public void testShort() {
        short c = 0;
        f1(c);
        f2(c);
        f3(c);
        f4(c);
        f5(c);
        f6(c);
        f7(c);
    }

    /**
     * 也是可以向上转，基本上除了char类型较为特殊，其它都可以自动向上转换
     */
    public void testInt() {
        int c = 0;
        f1(c);
        f2(c);
        f3(c);
        f4(c);
        f5(c);
        f6(c);
        f7(c);
    }

    public static void main(String[] args) {
        Part52 part52 = new Part52();
        part52.testChar();
        part52.testByte();
        part52.testShort();
        part52.testInt();
    }
}

